package org.example.mapper;

import org.apache.ibatis.annotations.Mapper;  
import org.apache.ibatis.annotations.Param;  
import org.apache.ibatis.annotations.Select;  
import org.apache.ibatis.annotations.Insert;  
import org.apache.ibatis.annotations.Update;  
import org.apache.ibatis.annotations.Delete;
import org.example.common.entity.Menu;

import java.util.List;  
  
@Mapper  
public interface MenuMapper {  
  
    // 插入菜单  
    @Insert("INSERT INTO sys_menu (id, name, path, component, icon, parent_id, sort, status, type) " +
            "VALUES (#{id}, #{name}, #{path}, #{component}, #{icon}, #{parentId}, #{sort}, #{status}, #{type})")  
    int insertMenu(Menu menu);
  
    // 根据ID查询菜单  
    @Select("SELECT * FROM sys_menu WHERE id = #{id}")
    Menu selectMenuById(@Param("id") String id);  
  
    // 查询所有菜单  
    @Select("SELECT * FROM sys_menu ORDER BY sort ASC")
    List<Menu> selectAllMenus();  
  
    // 更新菜单  
    @Update("" +
            "UPDATE sys_menu SET " +
            "name = #{name}, " +
            "path = #{path}, " +
            "component = #{component}, " +
            "icon = #{icon}, " +
            "parent_id = #{parentId}, " +
            "sort = #{sort}, " +
            "status = #{status}, " +
            "type = #{type} WHERE id = #{id}")
    int updateMenu(Menu menu);  
  
    // 删除菜单  
    @Delete("DELETE FROM sys_menu WHERE id = #{id}")
    int deleteMenu(@Param("id") String id);  

    List<Menu> selectByUserAllMenus(@Param("userId") long userId);
    // 其他可能的查询方法...  
}